﻿
#region Usings
using System;
using System.Security.Cryptography;
using Jenvin.Library.Utils.Encryption;
#endregion

namespace Jenvin.Library.Utils.Encryption
{
    /// <summary>
    /// MD5 function hash
    /// </summary>
    public class MD5Hash : IHash
    {

        /// <summary>
        /// 使用md5 计算 Hash 
        /// </summary>
        /// <param name="Input">Input string</param>
        /// <returns>A hash of the input string using MD5</returns>
        public string ComputeHash(string Input)
        {
            MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider();
            byte[] InputArray = System.Text.Encoding.ASCII.GetBytes(Input);
            byte[] HashedArray = MD5.ComputeHash(InputArray);
            MD5.Clear();
            return BitConverter.ToString(HashedArray).Replace("-", "");
        }

        public string Name
        {
            get { return "MD5"; }
        }
    }
}
